#include<bits/stdc++.h>

using namespace std;
using i64 = long long;

int read() {
	int x = 0, f = 0; char ch = getchar();
	while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = x * 10 + (ch - '0'), ch = getchar();
	return x;
}
int __stk[128], __len;
void put(i64 x) {
	if (x < 0) putchar('-'), x = -x;
	do { __stk[++__len] = x % 10; }while (x /= 10);
	while (__len) putchar(__stk[__len--] + '0');
}
const int N = 8e5 + 10, inf = 1e9;
int n;
int head[N], nxt[N << 1], to[N << 1], c[N << 1], cnt = 1;
void add(int u, int v, int w) {
	to[++cnt] = v, c[cnt] = w, nxt[cnt] = head[u], head[u] = cnt;
	to[++cnt] = u, c[cnt] = w, nxt[cnt] = head[v], head[v] = cnt;
}
i64 ans;
void dfs(int u, int w, int fa, int e) {
	if (fa) ans += w;
	for (int i = head[u]; i; i = nxt[i]) {
		int v = to[i];
		if (v == fa || (i >> 1) == e) continue;
		dfs(v, min(w, c[i]), u, e); 
	}
} 
int main() {
	freopen("tatooine.in", "r", stdin);
	freopen("tatooine.out", "w", stdout);
	n = read();
	for (int i = 1; i < n; ++i) {
		int u = read(), v = read();
		add(u, v, read());
	}
	for (int i = 1; i < n; ++i) {
		ans = 0;
		for (int j = 1; j <= n; ++j) dfs(j, inf, 0, i);
		put(ans >> 1), putchar('\n');
	}
	return 0;
}
